name: CLI Regression

on:
  push:
    branches:
      - "develop"
  pull_request:
    types: [opened, synchronize, reopened]

# Avoid duplicate workflows on same branch
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  cli_test:
    runs-on: ubuntu-latest

    defaults:
      run:
        shell: bash --login -eo pipefail {0}

    steps:
      - name: Checkout Streamlit code
        uses: actions/checkout@v4
        with:
          persist-credentials: false
          submodules: "recursive"
          fetch-depth: 2
      - name: Set Python version vars
        uses: ./.github/actions/build_info
      - name: Set up Python ${{ env.PYTHON_MAX_VERSION }}
        uses: actions/setup-python@v5
        with:
          python-version: "${{ env.PYTHON_MAX_VERSION }}"
      - name: Setup virtual env
        uses: ./.github/actions/make_init
      - name: Build Package - Fast
        timeout-minutes: 120
        run: |
          sudo apt install rsync
          BUILD_AS_FAST_AS_POSSIBLE=1 make package
      - name: Run CLI regression tests
        run: |
          export SKIP_VERSION_CHECK=true; make cli-regression-tests
